﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using TRPOP.CRM.Component.Common;
using TRPOP.CRM.Component.Business;
using TRPOP.CRM.Component.Model;
using TRPOP.Common;

namespace TRPOP.CRM.Web
{
    /// <summary>
    /// 保存 新增 跟踪类型
    /// </summary>
    public partial class FollowUpCategory_save : BaseAdmin
    {
        #region 权限限制
        protected override void SubPageInit()
        {
            base.m_oCurrentPermissionKey = "Sys_FollowUpCategory";
        }
        #endregion

        #region 页面变量
        private FollowUpCategoryInfo m_FollowUpCategoryInfo = new FollowUpCategoryInfo();
        #endregion

        #region 页面事件
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (RequestHelper.RequestInt("id") > 0)
                {
                    BindData();
                }
            }
        }
        //修改 新增 FollowUpCategory
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            if (ViewState["FollowUpCategory"] != null)
            {
                //修改
                m_FollowUpCategoryInfo = ViewState["JobFollowUpCategoryTitle"] as FollowUpCategoryInfo;
            }
            else
            {
                //新增
                m_FollowUpCategoryInfo.bIsDelete = false;
            }
            m_FollowUpCategoryInfo.nvcFollowUpCategoryName = txtFollowUpCategoryName.Text.HtmlEncode();
            m_FollowUpCategoryInfo.nvcDiscription = txtDescription.Text.HtmlEncode();

            //保存
            if (TRPOP.CRM.Component.Business.BaseManage.SaveFollowUpCategoryInfo(m_FollowUpCategoryInfo))
            {
                Alert("保存成功!", "FollowUpCategory_list.aspx");
            }
            else
            {
                Alert("保存失败!");
            }
        }

        #endregion

        #region 页面方法

        /// <summary>
        /// Bind FollowUpCategory By id
        /// </summary>
        protected void BindData()
        {
            m_FollowUpCategoryInfo = TRPOP.CRM.Component.Business.BaseManage.GetFollowUpCategoryInfoById(RequestHelper.RequestInt("id"));

            if (m_FollowUpCategoryInfo != null)
            {
                ViewState["FollowUpCategory"] = m_FollowUpCategoryInfo;
                txtFollowUpCategoryName.Text = m_FollowUpCategoryInfo.nvcFollowUpCategoryName.HtmlDecode();
                this.txtDescription.Text = m_FollowUpCategoryInfo.nvcDiscription.HtmlDecode();
            }
        }

        #endregion
    }
}